#ifndef MESH2D_H
#define MESH2D_H

#include "obj2d.h"
#include "tri2d.h"
#include "list.h"

namespace ePhys {

	class mesh2d :
		public obj2d
	{
	public:
		mesh2d(void);
		~mesh2d(void);

		inline OBJ_TYPE2D type(void) { return OBJ_MESH2D; }

		inline void setBuffer(tri2d *b, u32 s) { buf = b; bufSize = s; }
		inline tri2d *getBuffer(void) { return buf; }
		inline u32 getBufferSize(void) { return bufSize; }

		bool isInside(vec2d p);

	private:
		tri2d *buf;
		u32 bufSize;
	};

	class meshLoader2d {
	public:
		static mesh2d *makeMesh(tri2d *buf, u32 bufSize);		

		void addTriangle(tri2d tri);
		mesh2d *finish(void); 

	private:
		list<tri2d> tris;
	};

}
#endif